package git.soulbgm.yarn.wordcount;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.util.ToolRunner;

import java.util.Arrays;

/**
 * @author SoulBGM
 * @date 2021/11/18 0:07
 */
public class WordCountDriver {

    private static WordCountTool tool;

    public static void main(String[] args) throws Exception {
        // 1 创建配置文件
        Configuration conf = new Configuration();

        // 2 判断是否有tool接口
        switch (args[0]) {
            case "wordcount":
                tool = new WordCountTool();
                break;
            default:
                throw new RuntimeException("No such tool:" + args[0]);
        }

        // 3 用Tool执行程序
        int run = ToolRunner.run(conf, tool, Arrays.copyOfRange(args, 1, args.length));

        System.exit(run);
    }

}
